
import 'package:zfth/routers/Routers.dart';
import 'package:zfth/utils/JpushUtil.dart';
import 'package:zfth/utils/SPutil.dart';
import 'package:zfth/utils/Settings.dart';
import 'package:zfth/utils/StoreData.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:get/get.dart';


void main() async{
  //要想在启动之前，先初始化某些东西，必须加上这一句，否则报错
  WidgetsFlutterBinding.ensureInitialized();
  await SPutil.getInstance();
  StoreData.getInstance();
  //极光推送初始化
  JpushUtil.getInstance().init();

  SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
    // Brightness.light 状态栏字体颜色（白色）
    //   statusBarIconBrightness: Brightness.dark, // 状态栏字体颜色（黑色）
      statusBarColor: Settings.primaryColor // 状态栏背景色
  ));
  runApp(const MyApp());
}

class MyApp extends StatelessWidget{
  const MyApp({super.key});
  static final GlobalKey<NavigatorState> navigatorKey =  GlobalKey<NavigatorState>();

  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      navigatorKey: navigatorKey,
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
          platform: TargetPlatform.android,
          primaryColor: Settings.primaryColor,
          colorScheme: const ColorScheme.light().copyWith(
            primary: Settings.primaryColor,
          ),
          textTheme: const TextTheme()
      ),
      // home:  const HomePage(),
      initialRoute: "/",
      defaultTransition: Transition.rightToLeft,
      // onGenerateRoute: onGenerateRoute,

      //getx 定义路由
      getPages: getPages,
      builder: EasyLoading.init(),//EasyLoading 第三方组件需要这里先初始化
      localizationsDelegates: const [
        GlobalMaterialLocalizations.delegate,//指定本地化的字符串和一些其他的值
        GlobalWidgetsLocalizations.delegate,//定义 widget 默认的文本方向，从左到右或从右到左。
        GlobalCupertinoLocalizations.delegate,//对应的 Cupertino 风格（Cupertino 风格组件即 iOS 风格组件）
      ],
      supportedLocales: const [
        Locale('zh', 'CH'),
        Locale('en', 'US'),
      ],
    );





    // return MaterialApp(
    //   debugShowCheckedModeBanner: false,
    //   theme: ThemeData(
    //     platform: TargetPlatform.android,
    //     primaryColor: DefaultSettings.primaryColor,
    //     colorScheme: const ColorScheme.light().copyWith( // to use the primaryColor
    //       primary: DefaultSettings.primaryColor,
    //     ),
    //   ),
    //   // home:  const HomePage(),
    //   initialRoute: "/",
    //   onGenerateRoute: onGenerateRoute,
    //   builder: EasyLoading.init(),//EasyLoading 第三方组件需要这里先初始化
    // );

  }

}